<?php
/**
 * Created by PhpStorm.
 * User: jinji
 * Date: 2017/12/17
 * Time: 23:03
 */

namespace App\Services;
use Illuminate\Support\Facades\Mail;
use League\Flysystem\Exception;


class MailService{

    protected $recevicers = ['923611217@qq.com'];

    public function sendEmailReminder($data){
        $nickname = $data->nickname;
        $email    = $data->email;
        $website  = $data->website;
        if(empty($nickname)){
            return false;
        }
        try{
            foreach($this->recevicers as $recevicer){
                Mail::send('emails.mail',
                    ['nickname'=>$nickname,'email'=>$email,'website'=>$website],
                    function($message) use ($recevicer){
                        $message ->to($recevicer)->subject('联系|合作');
                    });
            }
        }catch (Exception $e){
            return false;
        }
        return true;
    }
}